﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Bakındur
{
    public abstract class Baslatici<T>
        where T : class
    {
        public virtual void Execute()
        {
            string cmd = string.Empty;

            if (IsWebAddress)
                cmd = string.Format("{0}{1}", Command, Arguments);
            else
                cmd = Command;

            using (Process p = new Process())
            {
                p.StartInfo = new ProcessStartInfo(cmd, Arguments);
                p.Start();
            }
        }

        public bool IsWebAddress
        {
            get
            {
                if (string.IsNullOrEmpty(Command)) return false;
                return Command.StartsWith("http") || Command.StartsWith("www") || Command.StartsWith("ftp");
            }
        }

        public abstract string Shortcut
        {
            get;
        }

        public abstract string Command
        {
            get;
        }

        public virtual string Arguments
        {
            get;
            set;
        }

        public virtual bool IsBusy
        {
            get;
            set;
        }

        protected T result;
        public virtual T Result
        {
            get
            {
                return result;
            }
        }
    }
}
